package cn.taichoo.server.controller;

import java.util.List;
import java.io.IOException;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import cn.taichoo.server.domain.PackUpgrade;
import cn.taichoo.server.service.IPackUpgradeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 手机打包业务-升级配置Controller
 *
 * @author Wuzh
 * @date 2025-03-17
 */
@Tag(name = "业务模块 - 手机打包业务-升级配置" )
@RestController
@RequestMapping("/upgrade" )
public class PackUpgradeController extends BaseController {

    @Resource
    private IPackUpgradeService packUpgradeService;

    /**
     * 查询手机打包业务-升级配置列表
     */
    @Operation(summary = "查询手机打包业务-升级配置列表" )
    @RequiresPermissions("server:upgrade:list" )
    @GetMapping("/list" )
    public TableDataInfo list(PackUpgrade packUpgrade) {
        startPage();
        List<PackUpgrade> list = packUpgradeService.selectPackUpgradeList(packUpgrade);
        return getDataTable(list);
    }

    /**
     * 导出手机打包业务-升级配置列表
     */
    @Operation(summary = "导出手机打包业务-升级配置列表" )
    @RequiresPermissions("server:upgrade:export" )
    @Log(title = "手机打包业务-升级配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, PackUpgrade packUpgrade) {
        List<PackUpgrade> list = packUpgradeService.selectPackUpgradeList(packUpgrade);
        ExcelUtil<PackUpgrade> util = new ExcelUtil<PackUpgrade>(PackUpgrade.class);
        util.exportExcel(response, list, "手机打包业务-升级配置数据" );
    }

    /**
     * 获取手机打包业务-升级配置详细信息
     */
    @Operation(summary = "获取手机打包业务-升级配置详细信息" )
    @RequiresPermissions("server:upgrade:query" )
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
        return success(packUpgradeService.selectPackUpgradeById(id));
    }

    /**
     * 新增手机打包业务-升级配置
     */
    @Operation(summary = "新增手机打包业务-升级配置" )
    @RequiresPermissions("server:upgrade:add" )
    @Log(title = "手机打包业务-升级配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PackUpgrade packUpgrade) {
        return packUpgradeService.insertPackUpgrade(packUpgrade);
    }

    /**
     * 修改手机打包业务-升级配置
     */
    @Operation(summary = "修改手机打包业务-升级配置" )
    @RequiresPermissions("server:upgrade:edit" )
    @Log(title = "手机打包业务-升级配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PackUpgrade packUpgrade) {
        return packUpgradeService.updatePackUpgradeById(packUpgrade);
    }

    /**
     * 删除手机打包业务-升级配置
     */
    @Operation(summary = "删除手机打包业务-升级配置" )
    @RequiresPermissions("server:upgrade:remove" )
    @Log(title = "手机打包业务-升级配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}" )
    public AjaxResult remove(@PathVariable Long id) {
        return packUpgradeService.deletePackUpgradeById(id);
    }
}
